function getImage2Base64(img) {
    let canvas = document.createElement('canvas')
    canvas.width = img.width
    canvas.height = img.height
    let ctx = canvas.getContext('2d')
    ctx.drawImage(img, 0, 0, img.width, img.height)
    let ext = img.src.substring(img.src.lastIndexOf('.') + 1).toLowerCase()
    let dataURL = canvas.toDataURL('image/' + ext)
    return dataURL
}

export  function getBase64(imgSrc) {
    // let base64 = ''
    let img = new Image()
    img.src = imgSrc
    // img.onload = () => {
    //   base64 = getImage2Base64(img)
    // }
    return getImage2Base64(img)
}